package com.stars.questions.deptQuestion.config.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.stars.base.entity.BaseEntity;
import com.stars.util.date.DateFormatUtils;

import java.util.Date;
import java.util.List;

/**
 * @author : Rocks
 * @version : 1.0
 * @date : 2022/10/2 21:20
 * @description : 指标实体类
 */
@TableName("QUESTION_CONFIG")
public class Question extends BaseEntity {

    private String id;

    @TableField("YEAR")
    private String year;

    @TableField("BT")
    private String bt;

    @TableField("NUM")
    private int num;

    @TableField("PUBLISH")
    private int publish;

    @TableField("STARTDATE")
    private Date startDate;

    @TableField("ENDDATE")
    private Date endDate;

    @TableField("MARK")
    private String mark;

    @TableField(exist = false)
    private String[] entryDate;

    @TableField(exist = false)
    private List<QuestionSub> questions;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getYear() {
        return year;
    }

    public void setYear(String year) {
        this.year = year;
    }

    public String getBt() {
        return bt;
    }

    public void setBt(String bt) {
        this.bt = bt;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public int getPublish() {
        return publish;
    }

    public void setPublish(int publish) {
        this.publish = publish;
    }

    public Date getStartDate() {
        if (entryDate != null && entryDate.length > 0) {
            return DateFormatUtils.parseDate(entryDate[0]);
        }
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        if (entryDate != null && entryDate.length > 1) {
            return DateFormatUtils.parseDate(entryDate[1]);
        }
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public String[] getEntryDate() {
        if(entryDate==null||entryDate.length<1){
            entryDate = new String[2];
            entryDate[0] = DateFormatUtils.formatDate(startDate);
            entryDate[1] = DateFormatUtils.formatDate(endDate);
        }
        return entryDate;
    }

    public void setEntryDate(String[] entryDate) {
        this.entryDate = entryDate;
    }

    public String getMark() {
        return mark;
    }

    public void setMark(String mark) {
        this.mark = mark;
    }

    public List<QuestionSub> getQuestions() {
        return questions;
    }

    public void setQuestions(List<QuestionSub> questions) {
        this.questions = questions;
    }
}
